<?php

namespace app\admin\model;

use app\common\model\TimeModel;
use think\Exception;

class BuddhaArticleClick extends TimeModel
{

    protected $name = "buddha_article_click";

    protected $deleteTime = "delete_time";

    
    
    public function getStatusList()
    {
        return ['0'=>'禁用','1'=>'启用',];
    }

    /**
     * @param array $data
     * @return bool|void
     * @throws Exception
     */
    public function insertSaveArticle(array $data = []){
        if(empty($data['openid'])){
            throw new Exception("类型错误");
        }
        try {
            $row = $this->where('openid', $data['openid'])
                ->where('article_id', $data['article_id'])
                ->find();
        }catch (\Exception $e){
            throw new Exception("查询失败");
        }
        if(!$row){
            return $this->save($data);
        }
    }
}